
import { defineStore } from 'pinia';
import { getCartList } from '@/api/cart.js'
export const useCartStore = defineStore('cart', {
    state: () => {
        return {
            // 所有这些属性都将自动推断出它们的类型
            count: 0,
            data: [],
        }
    },
    actions: {
        async getCart() {
            const res = await getCartList({ page: 1, limit: 100 });
            if (res.code === 1) {
                this.count = res.data.count;
                this.data = res.data.list;           
            }
        },
        // 重置数据
        reset() {
            this.count = 0;
            this.data= [];
        }
    }
})

